package cn.tannn.cat.file.server.init;

import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 页面处理
 *
 * @author tan
 */
@Slf4j
@Component
public class PageInit implements WebMvcConfigurer {


    @Override
    public void addResourceHandlers(@NotNull ResourceHandlerRegistry registry) {
        log.info("静态资源, 前缀会自定根据 server.servlet.context-path 变化");
        registry.addResourceHandler("/admin/css/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/static/css/");
        registry.addResourceHandler("/admin/js/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/static/js/");
        registry.addResourceHandler("/admin/sdk/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/static/sdk/");
        registry.addResourceHandler("/admin/image/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/static/image/");
        registry.addResourceHandler("/admin/pages/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/templates/pages/");
    }
}
